package com.cloudsigns.factorymanager2.produce.presenter.produce_team;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.produce_team.IPlanUnusualDailyFeedbackView;
import com.cloudsigns.factorymanager2.produce.model.produce_team.IPlanUnusualDailyFeedbackModel;
import com.cloudsigns.factorymanager2.produce.model.produce_team.PlanUnusualDailyFeedbackModel;

public class PlanUnusualDailyFeedbackPresenter {
    private IPlanUnusualDailyFeedbackView view;
    private IPlanUnusualDailyFeedbackModel model;
    private Handler handler = new Handler();

    public PlanUnusualDailyFeedbackPresenter(IPlanUnusualDailyFeedbackView view) {
        this.view = view;
        this.model = new PlanUnusualDailyFeedbackModel();
    }

    public void planUnusualDailyFeedback() {
        model.planUnusualDailyFeedback(view.getAdvice(), view.getAmount(), view.getOrderId(), view.getProductId(), view.getReason(), view.getWorkPartId(), view.getWorkPartOrderId(), new PlanUnusualDailyFeedbackModel.OnPlanUnusualDailyFeedbackListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.planUnusualDailyFeedbackSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(String desc) {
                view.planUnusualDailyFeedback(desc);
                view.hideLoading();
            }
        });
    }
}
